
Ext.define('DCApp.view.img.List', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.imglist',
    
    requires: [
        'DCApp.view.img.ListController',
        'DCApp.view.img.ListModel',
        'DCApp.view.GridFilters'
    ],

    // Connects to our View Controller (Ticket.view.ticket.SearchController) and View Model
    // (Ticket.view.ticket.SearchModel).
    controller: 'imglist',
    plugins: ['gfilters'],
    viewModel: {
        type: 'imglist'
    },
    header:false,
    selType: 'checkboxmodel',
    bind: {
        store: '{objs}'
    },
    tbar: [
			'->',{
			  	  xtype:'filefield',
				  listeners:{
				        afterrender:function(cmp){
				            cmp.fileInputEl.set({
				                multiple:'multiple'
				            });
				        }
				    }
			  },{
			      text: '上传',
			      handler: 'onUpload'
			  },{
			    text: '删除',
			    handler: 'onOpenImg'
			}
        ],
    
	bubbleEvents:['viewimg'],
	
	listeners: {
        itemdblclick: 'onImgDblClick'
    },
    
    columns: [
            {
                text     : '编号',
                dataIndex: 'imageId',
                filter: 'number'
            },
            {
                text     : '题名',
                dataIndex: 'imageName',
                filter: {
                    type: 'string',
                    itemDefaults: {
                        emptyText: 'Search for...'
                    }
                },
			   renderer:function(v,r,rec, rowIndex, columnIndex, store){
			   	//todo get formulas field uri
		        	var uri = rec.get('imageId') % 5+'.jpg'; 
		        	if(uri==""||uri==null){
		        	    img_src="../imgs/no-photo-available.jpg";  
		        	}else{
		        		img_src='../imgs/'+uri;
		        	}
				  	if(r){
				     	r.tdAttr="data-qtip=\"<img style='max-width:200px;max-height:200px;'  src='"+img_src+"'>\"";
				  	}
				    return v;
			    }
            },
            {
                text     : '光盘卷标',
                dataIndex: 'cdlabel'
            },
            {
                text     : '文件名',
                dataIndex: 'imgFile'
            },
            {
            	text:'影像来源',
            	dataIndex:'imageSource',
                filter: {
                    type: 'list',
                    options: DCApp.Cfg.OPTS.image_imageSource
                }
            },
            {
            	text:'有精细影像',
            	dataIndex:'isLivepicture',
            	filter: 'boolean'
            },
            {
            	xtype: 'datecolumn',
                text     : '最近修改',
                dataIndex: 'lastUpdate',
                formatter: 'date("m/d/Y")',
                filter: true  // use dataIndex first then fallback to column type
            }
            
        ],
    initComponent: function(){
    	 this.callParent();
    }
 });
